/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kungkhies.persistence.entities;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author clayton
 */
@Entity 
@Table(name = "download_stats")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "DownloadStats.findAll", query = "SELECT d FROM DownloadStats d"),
    @NamedQuery(name = "DownloadStats.findByKungkhieId", query = "SELECT d FROM DownloadStats d WHERE d.kungkhieId = :kungkhieId"),
    @NamedQuery(name = "DownloadStats.findByIsBlank", query = "SELECT d FROM DownloadStats d WHERE d.isBlank = :isBlank"),
    @NamedQuery(name = "DownloadStats.findByDownloads", query = "SELECT d FROM DownloadStats d WHERE d.downloads = :downloads"),
    @NamedQuery(name = "DownloadStats.findByDownloadDate", query = "SELECT d FROM DownloadStats d WHERE d.downloadDate = :downloadDate")
})
public class DownloadStats implements Serializable 
{
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "kungkhie_id")
    private Long kungkhieId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 5)
    @Column(name = "is_blank")
    private String isBlank;
    @Column(name = "downloads")
    private BigInteger downloads;
    @Basic(optional = false)
    @NotNull
    @Column(name = "download_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date downloadDate;
    @JoinColumn(name = "kungkhie_id", referencedColumnName = "kungkhie_id", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Kungkhie kungkhie;

    public DownloadStats()
    {
    }

    public DownloadStats(Long kungkhieId)
    {
        this.kungkhieId = kungkhieId;
    }

    public DownloadStats(Long kungkhieId, String isBlank, Date downloadDate)
    {
        this.kungkhieId = kungkhieId;
        this.isBlank = isBlank;
        this.downloadDate = downloadDate;
    }

    public Long getKungkhieId()
    {
        return kungkhieId;
    }

    public void setKungkhieId(Long kungkhieId)
    {
        this.kungkhieId = kungkhieId;
    }

    public String getIsBlank()
    {
        return isBlank;
    }

    public void setIsBlank(String isBlank)
    {
        this.isBlank = isBlank;
    }

    public BigInteger getDownloads()
    {
        return downloads;
    }

    public void setDownloads(BigInteger downloads)
    {
        this.downloads = downloads;
    }

    public Date getDownloadDate()
    {
        return downloadDate;
    }

    public void setDownloadDate(Date downloadDate)
    {
        this.downloadDate = downloadDate;
    }

    public Kungkhie getKungkhie()
    {
        return kungkhie;
    }

    public void setKungkhie(Kungkhie kungkhie)
    {
        this.kungkhie = kungkhie;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (kungkhieId != null ? kungkhieId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DownloadStats))
        {
            return false;
        }
        DownloadStats other = (DownloadStats) object;
        if ((this.kungkhieId == null && other.kungkhieId != null) || (this.kungkhieId != null && !this.kungkhieId.equals(other.kungkhieId)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "com.kungkhies.persistence.entities.DownloadStats[ kungkhieId=" + kungkhieId + " ]";
    }

}
